package com.finalproject.ui;
/**
 * representation of UI Map 
 */
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class UIMap  extends JPanel{
	
	public void paintComponent (Graphics g)
		{
			super.paintComponent(g);
			Graphics2D g2d = (Graphics2D) g;
			BufferedImage read;
			try {
				read = ImageIO.read(new File("Map-Medium.png"));
				 g.drawImage(read, 0, 0, null);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			
			
			setLayout(null);
			
//			JButton b1 = new JButton("V#1");
//			JButton b02 = new JButton("V#2");
//		    JButton b03 = new JButton("V#3");
//		    JButton b05 = new JButton("V#4");
//		    JButton b06 = new JButton("V#5");
//		    add(b1);
//		    add(b03);
//		    add(b02);
//		   add(b05);
//		   add(b06);

//		    Insets insets = getInsets();
//		    Dimension size = b1.getPreferredSize();
//		    b1.setBounds(145 + insets.left,125 + insets.top , size.width, size.height);
//		    b03.setBounds(300 + insets.left,250 + insets.top , size.width, size.height);
//		    
//		    b02.setBounds(80 + insets.left,300 + insets.top , size.width, size.height);
//		     b05.setBounds(95 + insets.left,400 + insets.top , size.width, size.height);
//		    b06.setBounds(300+ insets.left,400 + insets.top , size.width, size.height);
			   
//		    b1.setBounds(145 + insets.left,125 + insets.top , size.width, size.height);
//		    b1.setBounds(145 + insets.left,125 + insets.top , size.width, size.height);
//			   
		    
		    
//		    size = b03.getPreferredSize();
//		    b2
//		        .setBounds(55 + insets.left, 40 + insets.top, size.width,
//		            size.height);
//		    size = b3.getPreferredSize();
//		    b3.setBounds(150 + insets.left, 15 + insets.top, size.width,
//		        size.height);
		}
	
	
	
	public void addLocation(JButton jbutton, int[] corrdinates) {
		int left = corrdinates[0];
		int top = corrdinates[1];
		Dimension size = jbutton.getPreferredSize();
		Insets insets = getInsets();
		add(jbutton);
  	    jbutton.setBounds(left + insets.left,top + insets.top , size.width, size.height);
		
		
	}
	
	public static void main(String[] args) {
		JFrame f = new JFrame("FormLayout: Default Form Builder Example 1");

		f.setDefaultCloseOperation(2);
		f.getContentPane().add(new UIMap());
		f.pack();
		f.setSize(500, 600);

		f.setVisible(true);
	}

}
